package com.heima.user.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.heima.common.dto.ResponseResult;
import com.heima.user.dto.AuthDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heima.user.service.IApUserRealnameService;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * APP实名认证信息表 前端控制器
 * </p>
 *
 * @author lj
 * @since 2022-06-27
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/user_realname")
@Api(tags = "APP实名认证信息表接口")
@CrossOrigin
public class ApUserRealnameController{

    @Autowired
    private IApUserRealnameService apUserRealnameService;

    /**
     * 根据状态查询用户认证列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation(value = "用户审核", notes = "author:liJie")  // value指名称  notes 备注
    @ApiImplicitParam(name = "dto", value = "用户审核列表参数", required = true, dataType = "AuthDto")
    public ResponseResult listByStatus(@RequestBody AuthDto dto){
        log.info("[用户管理微服务======>用户审核，接收参数：{}]",dto.toString());
        return apUserRealnameService.listByStatus(dto);
    }

    /**
     * 审核通过
     *
     * @param dto
     * @return
     */
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto) {
        return apUserRealnameService.auth(dto, 1);
    }

    /**
     * 审核失败
     * @param dto
     * @return
     */
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        return apUserRealnameService.auth(dto, 0);
    }


}
